<template>
    <div id="risk-order-content" class="order-content">
        <el-row class="risk-order-top">
            <el-col :span="12" class="form-col col-box">
                <el-row class="form-content">
                    <BankHG
                        :renderCount="renderCountKey"
                        :key="renderCountKey"
                        :notMesh="notMesh"
                        :detail="detail"
                        @handleSettingValue="handleSettingValue(arguments)"
                        @getStockInfo="getStockInfo(arguments)"
                    />
                    <span class="title" style="color: #575757">已选质押券:</span>
                    <div style="margin-top: 5px; height: calc(100% - 290px)">
                        <!-- <risk-table :msg="selectedPledgePositionsListMsg" @handleBtn="handleDelSelect"></risk-table> -->
                        <vxe-table
                            :data="selectedList"
                            border
                            size="mini"
                            style="width: 100%"
                            height="100%"
                            auto-resize
                            resizable
                            :resizable-config="{ minWidth: '60' }"
                            show-header-overflow
                            header-align="center"
                        >
                            <vxe-column
                                v-for="(item, index) in selectedPledgePositionsListMsg.title"
                                :key="index + item.val"
                                :field="item.val"
                                :title="item.name"
                                :sortable="item.sortable"
                                :column-config="{ isHover: true }"
                                :row-config="{ isHover: true }"
                                :filters="item.filters"
                                :filter-method="filterHandler"
                                show-overflow
                                :min-width="item.minWidth"
                                :width="item.width"
                                :fixed="item.fixed"
                            >
                                <template #filter="{ $panel, column }" v-if="['stockCode', 'stockNameSt'].includes(item.val)">
                                    <div>
                                        <el-input
                                            class="my-input"
                                            type="type"
                                            v-for="(option, index) in column.filters"
                                            :key="index"
                                            v-model="option.data"
                                            @input="$panel.changeOption($event, !!option.data, option)"
                                        />
                                    </div>
                                </template>

                                <template slot-scope="scope">
                                    <el-button
                                        v-if="item.val === 'operate'"
                                        type="primary"
                                        icon="el-icon-close"
                                        @click="handleDelSelect(scope.row)"
                                        size="mini"
                                        class="tableButton"
                                    ></el-button>
                                    <!-- 券面总额 -->
                                    <RiskInputNumber
                                        v-else-if="item.val === 'totalFacePrice'"
                                        :input="scope.row.totalFacePrice"
                                        :field="'totalFacePrice'"
                                        :precision="4"
                                        :maxlength="15"
                                        @getInputNumber="getInputNumber(arguments, scope.row)"
                                    >
                                    </RiskInputNumber>

                                    <!-- 质押比率 -->
                                    <RiskInputNumber
                                        v-else-if="item.val === 'pledgeRatio'"
                                        :input="scope.row.pledgeRatio"
                                        :field="'pledgeRatio'"
                                        :precision="2"
                                        :inputAfter="'%'"
                                        :maxlength="15"
                                        @getInputNumber="getInputNumber(arguments, scope.row)"
                                    >
                                    </RiskInputNumber>

                                    <!-- 质押数量 -->
                                    <!-- <RiskInputNumber
                                        v-else-if="item.val === 'pledgedQty'"
                                        :input="scope.row.pledgedQty"
                                        :field="'pledgedQty'"
                                        :disabled="true"
                                        :maxlength="15"
                                        @getInputNumber="getInputNumber(arguments, scope.row)"
                                    >
                                    </RiskInputNumber> -->

                                    <!-- 质押金额 -->
                                    <RiskInputNumber
                                        v-else-if="item.val === 'balance'"
                                        :input="scope.row.balance"
                                        :field="'balance'"
                                        :disabled="true"
                                        :maxlength="15"
                                        :precision="4"
                                        @getInputNumber="getInputNumber(arguments, scope.row)"
                                    >
                                    </RiskInputNumber>
                                    <span v-else-if="['currentAmount', 'facePrice', 'totalPrice', 'balance'].includes(item.val)" style="float: right">
                                        {{ scope.row[item.val] != undefined ? numberFormat(scope.row[item.val], 2) : '--' }}
                                    </span>

                                    <span v-else-if="item.val === 'endDate'" style="display: block; text-align: center">
                                        {{ dateFormat(scope.row[item.val]) || '--' }}
                                    </span>

                                    <span v-else>{{ scope.row[item.val] || '--' }}</span>
                                </template>
                            </vxe-column>
                        </vxe-table>
                    </div>
                </el-row>
                <el-row class="form-operate">
                    <el-col :span="7">
                        <i style="font-size: 25px" name="entrySetting" class="el-icon-setting iconClass" @click="openEntryGroup"></i>
                    </el-col>
                    <el-col :span="17">
                        <el-button name="重置" size="mini" @click="handleResetForm">重置</el-button>
                        <el-button name="试算" type="primary" @click="test" size="mini">试算</el-button>
                        <el-button name="下单" type="primary" @click="handlePlaceOrderClick" size="mini">下单</el-button>
                    </el-col>
                </el-row>
            </el-col>
            <el-col :span="12" class="col-box col-box2">
                <el-tabs type="card" v-model="activePane">
                    <el-tab-pane label="可质押债券信息" name="1">
                        <div class="pledge" style="height: calc(100% - 38px)">
                            <vxe-table
                                :data="pledgePositionsListMsg.returnData.data"
                                border
                                size="mini"
                                style="width: 100%"
                                auto-resize
                                height="100%"
                                resizable
                                :key="pledgeTableKey"
                                :resizable-config="{ minWidth: '60' }"
                                show-header-overflow
                                @filter-change="handleFilterPledge"
                                :filter-config="{ remote: true, iconNone: 'el-icon-search', iconMatch: 'el-icon-search' }"
                                header-align="center"
                            >
                                <vxe-column
                                    v-for="(item, index) in pledgePositionsListMsg.title"
                                    :key="index + item.val"
                                    :field="item.val"
                                    :title="item.name"
                                    :sortable="item.sortable"
                                    :column-config="{ isHover: true }"
                                    :row-config="{ isHover: true }"
                                    :filters="item.filters"
                                    show-overflow
                                    :min-width="item.minWidth"
                                    :width="item.width"
                                    :fixed="item.fixed"
                                >
                                    <template #filter="{ $panel, column }" v-if="['stockCode', 'stockNameSt'].includes(item.val)">
                                        <div>
                                            <el-input
                                                class="my-input"
                                                type="type"
                                                v-for="(option, index) in column.filters"
                                                :key="index"
                                                v-model="option.data"
                                                @input="$panel.changeOption($event, !!option.data, option)"
                                            />
                                        </div>
                                    </template>

                                    <template slot-scope="scope">
                                        <el-button
                                            v-if="item.val === 'operate'"
                                            type="primary"
                                            icon="el-icon-check"
                                            @click="handleSelect(scope.row)"
                                            :disabled="scope.row.disabled"
                                            size="mini"
                                            class="tableButton"
                                        ></el-button>
                                        <span v-else-if="['currentAmount', 'facePrice', 'totalPrice', 'balance'].includes(item.val)">
                                            {{ scope.row[item.val] != undefined ? numberFormat(scope.row[item.val], 2) : '--' }}
                                        </span>

                                        <span v-else-if="item.val === 'endDate'" style="display: block; text-align: center">
                                            {{ dateFormat(scope.row[item.val]) || '--' }}
                                        </span>
                                        <span v-else>{{ scope.row[item.val] || '--' }}</span>
                                    </template>
                                </vxe-column>
                            </vxe-table>
                        </div>
                        <el-pagination
                            background
                            @current-change="getPledgeList"
                            layout="total, prev, pager, next"
                            :current-page="pages.currentPage"
                            :page-size="pages.pageSize"
                            :total="pledgePositionsListMsg.returnData.total"
                        >
                        </el-pagination>

                        <!-- <risk-table
                            :msg="pledgePositionsListMsg"
                            @handleBtn="handleSelect"
                            @getList="getPledgeList"
                            @handleFilter="handleFilterPledge"
                        ></risk-table> -->
                    </el-tab-pane>

                    <el-tab-pane label="产品持仓信息" name="2">
                        <risk-table
                            class="position"
                            :msg="fundPositionsListMsg"
                            @getList="getFundPositionList"
                            @handleFilter="handleFilterFundPosition"
                        ></risk-table>
                    </el-tab-pane>
                </el-tabs>
            </el-col>
        </el-row>
        <el-row class="risk-order-bottom">
            <el-col class="col-box">
                <h3>
                    <el-row class="result-span">
                        <el-col :span="3">
                            <span>风控结果:</span>
                            <status-tag :code="riskResult"></status-tag>
                        </el-col>
                        <el-col :span="6">
                            <span>试算/下单时间: </span>
                            <span style="color: red">{{ calcTime }}</span>
                        </el-col>
                        <el-col :span="5">
                            <span>计算耗时: </span>
                            <span style="color: red">{{ takeTime }}</span>
                        </el-col>
                        <el-col :span="6">
                            <span>条目检查数:</span>
                            <span v-show="riskResultTable.length" style="color: red">{{ this.riskResultTable.length }}</span>
                        </el-col>
                        <el-col :span="4">
                            <el-button style="float: right" type="primary" size="mini" @click="layoutDialog = true">布局设置</el-button>
                            <!-- <el-checkbox v-model="thresholdTypeFilter['1']" @change="handelThresholdTypeFilter('1')">显示触警</el-checkbox>
                            <el-checkbox v-model="thresholdTypeFilter['0']" @change="handelThresholdTypeFilter('0')">显示合规</el-checkbox> -->
                        </el-col>
                    </el-row>
                </h3>
                <!-- <div> -->
                <vxe-table
                    :key="tableKey"
                    :auto-resize="true"
                    :data="riskResultTable"
                    border
                    size="mini"
                    style="width: 100%"
                    height="90%"
                    v-loading="calcLoading"
                    resizable
                    :resizable-config="{ minWidth: '60' }"
                    show-header-overflow
                    :sort-config="{ defaultSort: { field: 'thresholdType', order: 'desc' }, sortMethod: customSortMethod }"
                    header-align="center"
                >
                    <vxe-column
                        v-for="(item, index) in showFieldList"
                        :key="index + item.id"
                        :field="item.id"
                        :title="item.content"
                        :sortable="item.sortable"
                        :column-config="{ isHover: true }"
                        :row-config="{ isHover: true }"
                        :filters="item.filters"
                        :filter-method="item.filterMethod"
                        show-overflow
                        min-width="120"
                    >
                        <template
                            #filter="{ $panel, column }"
                            v-if="
                                [
                                    'fundCode',
                                    'fundNameSt',
                                    'assetCode',
                                    'assetName',
                                    'fundAccountCode',
                                    'fundAccountName',
                                    'stockCode',
                                    'stockNameSt',
                                    'entryCode',
                                    'entryName',
                                ].includes(item.id)
                            "
                        >
                            <div>
                                <el-input
                                    class="my-input"
                                    type="type"
                                    v-for="(option, index) in column.filters"
                                    :key="index"
                                    v-model="option.data"
                                    @input="$panel.changeOption($event, !!option.data, option)"
                                />
                            </div>
                        </template>
                        <template slot-scope="scope">
                            <span v-if="item.id === 'entryType'">{{ entryType[scope.row.entryType] }}</span>
                            <span v-else-if="item.id === 'compareType'">{{ compareDirection[scope.row.compareType] }}</span>
                            <status-tag v-else-if="item.id === 'thresholdType'" :code="scope.row.thresholdType" />
                            <branch-tag v-else-if="item.id === 'branchNum'" :data="scope.row" />
                            <span v-else-if="['investableBalance', 'maxTradable', 'maxTradableMerge'].includes(item.id)">
                                <el-popover
                                    v-if="getObjectLength(scope.row[item.id]) && getObjectLength(scope.row[item.id]) > 1"
                                    placement="top"
                                    trigger="hover"
                                >
                                    <div style="padding: 0 10px 10px 0" slot v-for="(value, key, index) in scope.row[item.id]" :key="key">
                                        {{ '阀值' + ++index + getShowName(item.id) + ': ' + scope.row[item.id][getParamName(item.id) + index] }}
                                    </div>
                                    <el-tag slot="reference">{{ getObjectLength(scope.row[item.id]) + '个' + getShowName(item.id) }}</el-tag>
                                </el-popover>
                                <span
                                    v-else-if="getObjectLength(scope.row[item.id])"
                                    v-for="(value, key) in scope.row[item.id]"
                                    :key="key"
                                    style="float: right"
                                    >{{ value }}</span
                                >
                                <span v-else style="float: right"> --</span>
                            </span>
                            <span v-else-if="item.id === 'calculateValue'" style="float: right">{{
                                scope.row[item.id] != undefined ? numberFormat(scope.row[item.id], scope.row.unit) + unitShow(scope.row.unit) : '--'
                            }}</span>
                            <span v-else-if="item.id === 'thresholdValue'" style="float: right">{{
                                scope.row[item.id] != undefined ? numberFormat(scope.row[item.id], scope.row.unit) + unitShow(scope.row.unit) : '--'
                            }}</span>
                            <span v-else>{{ scope.row[item.id] }}</span>
                        </template>
                    </vxe-column>
                </vxe-table>
                <!-- </div> -->
            </el-col>
        </el-row>
        <RiskTableLayout
            title="页面布局"
            :visible.sync="layoutDialog"
            :field-list="tableColumns"
            :selected-field-list="selectedFieldList"
            :fixed-field-list="fixedFieldList"
            table-name="RE_TRIAL_CALCULATE"
            @on-submit="onSubmit"
        />

        <EntryGroupSetting
            v-if="transDialog"
            :resourceCode="resourceCode"
            :transDialog="transDialog"
            @getEntryGroup="getEntryGroup"
            @closeEntryDialog="closeEntryDialog"
        />

        <!--处理下单后的弹窗-->
        <RiskOrderResultAfter
            v-if="orderCancelShow"
            :key="riskOrderResultAfterKey"
            :riskResultThresholdType="result"
            :res="riskOrderResultTable"
            @riskResultContinue="riskResultContinue"
            @riskResultCancel="riskResultCancel"
        />
    </div>
</template>
<script lang="ts">
import { getCurrentPageData, UUID, numberFormat, unitShow, dateFormat, getConfigItem } from '@/utils/tools';
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import BankHG from '../components/bank-hg.vue';
import Invest from '@/common/dict/invest';
import RiskTableLayout from '@/common/components/risk-table-layout.vue';
import { getActiveMenuCode, getUser } from '@/utils/user-util';
import DictionConstUtil, { SGU_CACHE } from '@/utils/diction-const-util';
import RiskTable from '@/common/components/risk-table.vue';
import { foundStockExistAsync, getSystemTradeDay } from '../api';
import moment from 'moment';
import ColumnUtil from '../utils/column-util';
import StatusTag from '@/pages/risk-measure/components/status-tag.vue';
import BranchTag from '@/pages/risk-measure/components/branch-tag.vue';
import RiskInputNumber from '@/pages/risk-measure/components/risk-input-number.vue';
import { trialCalculate, cancelCommonOrder } from '@/common/api/instruction';
import RiskOrderResultAfter from '@/pages/risk-time/components/risk-order-result-after.vue';
import EntryGroupSetting from '../components/entry-group-seting.vue';
export interface pages {
    total?: number;
    pageSize?: number;
    currentPage?: number;
}
@Component({
    name: 'BuyBackRiskOrder',
    components: {
        BankHG,
        RiskTableLayout,
        RiskTable,
        StatusTag,
        BranchTag,
        RiskInputNumber,
        RiskOrderResultAfter,
        EntryGroupSetting,
    },
})
export default class BuyBackRiskOrder extends Vue {
    numberFormat = numberFormat;
    dateFormat = dateFormat;
    unitShow = unitShow;
    @Prop()
    detail: any;
    @Prop()
    selectedPledgeList: any;
    ColumnUtil = new ColumnUtil();
    resourceCode: string = '';
    SHOW_SECURITY = getConfigItem('SHOW_SECURITY');
    // 下单类型转换
    InstTypePojo = {
        '1': '1',
        '2': '1',
        '3': '2',
        '4': '2',
        '5': '3',
        '6': '1',
        '7': '6',
        '8': '8',
    };

    Invest: any = new Invest();
    // 显示的标签页
    activePane: string = '1';

    // 风控结果表数据
    riskResultTable: any[] = [];

    // 条目组穿梭框
    transDialog: boolean = false;

    layoutDialog: boolean = false;

    // 产品持仓信息相关
    fundPositionsListMsg = {
        returnData: { data: [], total: 0 },
        dataKey: 'data',
        title: this.ColumnUtil.repoPositionColums,
        height: '100%',
        // 隐藏页码
        hidePage: false,
        showFooter: true,
        footerColumns: 'ghBalance',
        checked: { on: false, option: false },
    };

    // 可选质押券信息相关
    pledgePositionsListMsg = {
        returnData: { data: [], total: 0 },
        dataKey: 'data',
        title: this.ColumnUtil.pledgeColumns,
        height: '100%',
        // 隐藏页码
        hidePage: false,
        checked: { on: false, option: false },
    };

    // 已选质押券信息相关
    selectedPledgePositionsListMsg = {
        returnData: { data: [], total: 0 },
        dataKey: 'data',
        title: this.ColumnUtil.selectedPledgeColumns,
        height: '100%',
        // 隐藏页码
        hidePage: true,
        checked: { on: false, option: false },
    };

    // 全部表格列
    tableColumns: any[] = [
        { content: '产品代码', id: 'fundCode', sortable: false },
        { content: '产品名称', id: 'fundNameSt', sortable: false },
        { content: '证券代码', id: 'stockCode', sortable: true },
        { content: '证券名称', id: 'stockNameSt', sortable: false },
        { content: '条目编号', id: 'entryCode', sortable: true },
        { content: '风险说明', id: 'entryName', sortable: false },
        { content: '风险类型', id: 'entryType', sortable: false },
        { content: '风控阈值', id: 'thresholdValue', sortable: false },
        { content: '比较方向', id: 'compareType', sortable: false },
        { content: '计算结果(单位)', id: 'calculateValue', sortable: false },
        { content: '阈值类型', id: 'thresholdType', sortable: true },
        { content: '可投余量', id: 'investableBalance', sortable: false },
        { content: '最大可交易量', id: 'maxTradable', sortable: false },
        { content: '最大可交易量(汇总)', id: 'maxTradableMerge', sortable: false },
        { content: '静态条目KEY', id: 'entryKey', sortable: false },
        { content: '分支详情', id: 'branchNum', sortable: false },
    ];
    // 要显示的表格列
    showFieldList: any[] = [];
    // 已选择字段列表
    selectedFieldList: any[] = [];
    // 固定字段列表
    fixedFieldList: any[] = [
        { content: '产品代码', id: 'fundCode', sortable: true },
        { content: '产品名称', id: 'fundNameSt', sortable: false },
    ];
    // 风险类型
    entryTypeArr: any[] = [];
    // 阈值类型
    ThresholdTypeArr: any[] = [];
    allStockType: any[] = [];

    // 图标dom
    iconDom: any = null;
    tableKey: number = 0;
    calcLoading: boolean = false;

    instruction: any = {};
    instructionCache: any = {};
    stockInfoCache: any = {};
    stockInfo: any = {};
    entryType = {}; // 风险类型字典
    compareDirection = {}; // 比较方向字典
    marketCodePojo: any = {};
    OrderDirection: any = {};
    tradeDays: any[] = []; // 交易日

    calcTime: string = ''; // 下单/试算时间
    takeTime: string | number = ''; // 计算耗时
    riskResult: string | number = ''; // 风控结果
    directMode: string = '0'; // 是否从严控制，默认0，从严

    fundCodeSelectData: any[] = []; // 产品序号下拉框数据
    stockInfoPojo: any = {};
    activeKey: string = '4';
    renderCountKey: number = 0;

    fundpositionList: any[] = [];
    stockpositionList: any[] = [];

    // 模块详情穿梭框数据
    tranColumns: any[] = [
        {
            label: '编号',
            prop: 'groupCode',
            width: 80,
        },
        {
            label: '名称',
            prop: 'groupName',
        },
    ];

    dataSourceLeft: any[] = [];
    dataSourceCalculateRight: any[] = [];
    dataSourceExcludeRight: any[] = [];
    selectKeyLeft: any[] = []; // 左边选中的key
    selectKeyCalculateRight: any[] = []; // 右边选中的key
    selectKeyExcludeRight: any[] = []; // 右边选中排除的key
    entryGroups: any[] = [];

    selectEntryGroupCode = {
        calculateEntryGroup: [],
        excludeEntryGroup: [],
    };

    // 分页
    pages = { currentPage: 1, pageSize: 25 };
    verInt: boolean = false;
    form: any = {};
    isPlaceOrder: boolean = false;
    notMesh: boolean = true;
    result: string = '';
    isUpdate: boolean = false;
    oldOuterOrderCode: string = '';
    serialNo: string = '';

    fundFilterList: any[] = [];
    pledgeFilterList: any[] = [];
    stockCode1: string = '';
    stockName1: string = '';
    selectedList: any[] = [];
    pledgePOList: any[] = [];
    stockCode2: string = '';
    stockName2: string = '';
    pledgeTableKey: number = 0;
    stockTypePojo: any = {};
    pledgeList: any[] = [];

    riskOrderResultTable: any[] = [];
    orderCancelShow: boolean = false;
    riskOrderResultAfterKey: number = 0;

    @Watch('instructionCache.fundCode', { immediate: true, deep: true })
    onWatchFundCode(newValue, oldValue) {
        if (JSON.stringify(newValue) != JSON.stringify(oldValue)) {
            if (newValue && oldValue) {
                this.selectedList = [];
            }
            // if (!this.isUpdate) {
            //     this.selectedList = [];
            //     // this.isUpdate = false;
            // }
            // this.isUpdate = false;
            // 清除可选质押券表格筛选条件
            this.pledgeFilterList = [];
            this.pledgeTableKey++;
            // 查询产品持仓
            this.getFundPositionList(this.pages);
            // 查询质押券信息
            this.getPledgeList(this.pages.currentPage);
        }
    }

    @Watch('detail', { immediate: true, deep: true })
    onWatchDetail(newValue, oldValue) {
        // debugger;
        this.renderCountKey++;

        // this.isUpdate = true;
        if (this.detail?.instNo) {
            this.isUpdate = true;
            this.oldOuterOrderCode = this.detail.outerOrderCode;
            this.serialNo = this.detail.serialNo;

            // this.isUpdate++;
            // this.cancelOrder.instNo = this.detail.instNo;
            // this.cancelOrder.originOuterOrderCode = this.detail.outerOrderCode;
            this.pledgeList = JSON.parse(JSON.stringify(this.selectedPledgeList));

            let tempData: any = this.selectedPledgeList.forEach(ele => {
                ele.fundAcCode = ele.fdAcCode;
                ele.fundAcName = ele.fdAcName;
                ele.pledgeRatio = ele.pledgeRate;
                ele.pledgedQty = ele.pledgeAmount;
                ele.stockNameSt = ele.stockName;
                // ele.totalFacePrice = ele.totalFacePrice / 10000;
                // ele.balance = ele.balance / 10000;
            });
            this.selectedList = JSON.parse(JSON.stringify(this.selectedPledgeList));
            let seletedIds = [];
            this.selectedList.forEach(ele => {
                seletedIds.push(ele.positionId);
            });
            // let isExist = false;
            this.pledgePositionsListMsg.returnData.data.forEach(ele => {
                if (seletedIds.includes(ele.positionId)) {
                    ele['disabled'] = true;
                } else {
                    ele['disabled'] = false;
                }
            });
        } else {
            this.isUpdate = false;
        }
    }

    async mounted() {
        this.tableColumns = this.ColumnUtil.handleResultColumns(this.tableColumns, 'id');
        this.resourceCode = getActiveMenuCode().defaultActive;
        this.entryTypeArr = this.objToArr(this.Invest.entryType);
        this.ThresholdTypeArr = this.objToArr(this.Invest.ThresholdType);
        this.getUserSelectEntryGroupList();
        getSystemTradeDay().then(res => {
            this.tradeDays = res.map(item => Number(item)).sort((a, b) => a - b);
        });
        this.queryLayout();
        // 获取产品信息 (产品序号下拉框数据)
        this.fundCodeSelectData = await SGU_CACHE('FundInfo', '/fundInfo/list', []);
        // 获取风险类型字典
        this.entryType = this.Invest.entryType;
        // 获取比较方向字典
        this.compareDirection = this.Invest.CompareDirection;

        this.stockTypePojo = DictionConstUtil.ListToPojo(await SGU_CACHE('StockType', '/dict/stockType/list', []));
        this.marketCodePojo = DictionConstUtil.ListToPojo(await DictionConstUtil.FNMarketType());
        this.OrderDirection = DictionConstUtil.ListToPojo(await DictionConstUtil.FNTradeDirection());
    }

    // 指令事件回调
    handleSettingValue(msg: any) {
        // let data = JSON.parse(JSON.stringify(msg[0]));
        this.instructionCache = JSON.parse(JSON.stringify(msg[0]));
    }

    getInputNumber(args: any, row: any) {
        // debugger;
        let value = args[0];
        let field = args[1];
        row[field] = value;
        if (field === 'totalFacePrice') {
            // 质押数量 = 券面总额 * 10000 / 100
            // row['pledgedQty'] = (Number(row['totalFacePrice'] || 0) * 10000) / 100;
            // 质押数量 = 实时持仓数量
            row['pledgedQty'] = row['currentAmount'];
            // 质押金额 = 券面总额 * 质押比率 / 100
            row['balance'] = (Number(row['totalFacePrice']) * Number(row['pledgeRatio'])) / 100;
        } else if (field === 'pledgeRatio') {
            row['balance'] = (Number(row['totalFacePrice']) * Number(row['pledgeRatio'])) / 100;
        }
        this.pledgePOList = this.selectedList.map(ele => {
            return {
                // totalFacePrice: String(ele.totalFacePrice || ''),
                totalFacePrice: String(Number(ele.totalFacePrice || '0') * 10000 || ''),

                fundAccountCode: ele.fundAcCode,
                pledgeRatio: ele.pledgeRatio,
                pledgedQty: ele.pledgedQty,
                investType: ele.investType,
                marketCode: ele.marketCode,
                reportCode: ele.stockCode.split(' ')[0] || '',
            };
        });
    }

    getStockInfo(args: any) {
        this.stockInfo = args[0];
        this.stockInfoCache = this.stockInfo || {};
    }

    // 重置按钮事件
    handleResetForm() {
        this.renderCountKey++;
        this.$emit('reset', null);
        this.fundPositionsListMsg.returnData.data = [];
        this.fundPositionsListMsg.returnData.total = 0;
        this.pledgePositionsListMsg.returnData.data = [];
        this.pledgePositionsListMsg.returnData.total = 0;
        this.selectedList = [];
        this.isUpdate = false;
    }

    // 产品持仓信息分页
    getFundPositionList(pages) {
        let form: any = {};
        // 判断是否带过滤条件
        if (!this.fundFilterList.length) {
            form = {
                fundCode: [this.instructionCache.fundCode],
                paging: pages,
            };
        } else {
            form = {
                stockCode: this.stockCode1,
                stockName: this.stockName1,
                fundCode: [this.instructionCache.fundCode],
                paging: pages,
            };
        }
        // 获取产品持仓信息
        this.$axios.post('/position/bankRepo/fund', form).then((res: any) => {
            res.list.forEach(ele => {
                ele.stockType = this.stockTypePojo[ele.stockType];
            });
            this.fundPositionsListMsg.returnData.data = res.list;
            this.fundPositionsListMsg.returnData.total = res.total;
        });
    }

    handleFilterFundPosition(filterList: any) {
        this.fundFilterList = filterList;
        this.stockCode1 = '';
        this.stockName1 = '';
        if (filterList.length) {
            let code = filterList.find(ele => ele.property === 'stockCode');
            let name = filterList.find(ele => ele.property === 'stockNameSt');
            this.stockCode1 = code?.datas[0] || '';
            this.stockName1 = name?.datas[0] || '';
        }
        this.getFundPositionList(this.pages);
    }

    handlePledgeList() {
        let selectedPositionIds = JSON.parse(JSON.stringify(this.selectedList.map(ele => ele.positionId)));
        this.pledgePositionsListMsg.returnData.data.forEach(ele => {
            if (selectedPositionIds.includes(ele.positionId)) {
                ele['disabled'] = true;
            } else {
                ele['disabled'] = false;
            }
        });
    }

    // 质押券信息分页
    getPledgeList(currentPage) {
        let form: any = {};
        let pages = { currentPage: currentPage, pageSize: 25 };
        // 判断是否带过滤条件
        if (!this.pledgeFilterList.length) {
            form = {
                fundCode: [this.instructionCache.fundCode],
                paging: pages,
            };
        } else {
            form = {
                stockCode: this.stockCode2,
                stockNameSt: this.stockName2,
                fundCode: [this.instructionCache.fundCode],
                paging: pages,
            };
        }
        // 获取质押券信息
        this.$axios.post('position/stock/pledge', form).then((res: any) => {
            this.pledgePositionsListMsg.returnData.data = res.list;
            this.pledgePositionsListMsg.returnData.total = res.total;
            // if (this.isUpdate) {

            // }
            this.handlePledgeList();
        });
    }

    handleFilterPledge({ column, property, values, datas, filterList, $event }) {
        this.pledgeFilterList = filterList;
        this.stockCode2 = '';
        this.stockName2 = '';
        if (filterList.length) {
            let code = filterList.find(ele => ele.property === 'stockCode');
            let name = filterList.find(ele => ele.property === 'stockNameSt');
            this.stockCode2 = code?.datas[0] || '';
            this.stockName2 = name?.datas[0] || '';
        }
        this.getPledgeList(1);
    }

    // 取消选中质押券事件
    handleDelSelect(row: any) {
        this.selectedList = this.selectedList.filter(item => item.positionId !== row.positionId);
        this.selectedPledgePositionsListMsg.returnData.data = this.selectedList;
        this.pledgePOList = this.selectedList.map(ele => {
            return {
                // totalFacePrice: String(ele.totalFacePrice || ''),
                totalFacePrice: String(Number(ele.totalFacePrice || '0') * 10000 || ''),
                fundAccountCode: ele.fundAcCode,
                pledgeRatio: ele.pledgeRatio,
                pledgedQty: ele.pledgedQty,
                investType: ele.investType,
                marketCode: ele.marketCode,
                reportCode: ele.stockCode.split(' ')[0] || '',
            };
        });
        this.handlePledgeList();
    }

    // 选中质押券事件
    handleSelect(row: any) {
        let isExist = false;
        for (let i = 0; i < this.selectedList.length; i++) {
            if (this.selectedList[i]['custodianName'] !== row.custodianName) {
                isExist = true;
                break;
            }
        }
        if (isExist) {
            this.yh_message_warn('已选质押券必须属于同一托管机构！');
        } else {
            let obj = {
                totalFacePrice: row.totalPrice,
                pledgeRatio: '100',
                pledgedQty: row['currentAmount'],
                balance: '',
            };
            obj.balance = String((Number(obj.totalFacePrice || '0') * Number(obj.pledgeRatio || '0')) / 100);
            this.selectedList.unshift({ ...obj, ...row });
            this.selectedPledgePositionsListMsg.returnData.data = this.selectedList;
            this.handlePledgeList();

            this.pledgePOList = this.selectedList.map(ele => {
                return {
                    // totalFacePrice: String(ele.totalFacePrice || ''),
                    totalFacePrice: String(Number(ele.totalFacePrice || '0') * 10000 || ''),

                    fundAccountCode: ele.fundAcCode,
                    pledgeRatio: ele.pledgeRatio,
                    pledgedQty: ele.pledgedQty,
                    investType: ele.investType,
                    marketCode: ele.marketCode,
                    reportCode: ele.stockCode.split(' ')[0] || '',
                };
            });
        }
    }

    // 校验指令信息
    async verifyInstructionParam(instruction, stockInfo) {
        let verify: any = {};
        if (!instruction) {
            this.yh_message_warn('请完善指令信息!');
            return false;
        }

        if (instruction.instType == '4') {
            verify = {
                fundCode: '产品代码',
                fundAccountCode: '组合编码',
                orderRate: '回购利率',
                orderBalance: '回购金额',
                repoDay: '回购天数',
                orderDirection: '委托方向',
                factUseMoney: '实际占款天数',
                clearSpeed: '清算速度',
                shouldInterest: '应计利息',
                firstSettleDate: '首次结算日期',
                endSettleDate: '到期结算日期',
                expirePayBalance: '到期购回金额',
                // opponentCode: '交易对手',
            };

            if (instruction.firstSettleDate && instruction.endSettleDate) {
                let beginDate = new Date(instruction.firstSettleDate.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1/$2/$3'));
                let endDate = new Date(instruction.endSettleDate.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1/$2/$3'));
                if (beginDate > endDate) {
                    this.yh_message_warn('到期日期必须大于等于结算日期');
                    return false;
                }
            }
        }
        for (let key in verify) {
            if (!instruction[key] && key !== 'orderPriceType') {
                this.yh_message_warn(verify[key] + ' 不可为空');
                return false;
            }
        }

        if (instruction.orderRate == 0.0) {
            this.yh_message_warn('请输入正确的回购利率');
            return false;
        }

        if (instruction.orderRate > 100) {
            this.yh_message_warn('回购利率在0-100(包含)之间');
            return false;
        }
        if (stockInfo.stockCode) {
            let res = await foundStockExistAsync({ dictKey: stockInfo.stockCode }).catch(() => {});
            if (!res || Number(res) === 0) {
                this.yh_message_warn('回购天数不合理，请重新输入');
                return false;
            }
        }

        for (let index = 0; index < this.selectedList.length; index++) {
            if (this.selectedList[index]['totalFacePrice'] <= 0) {
                this.yh_message_warn('"券面总额"须大于0！');
                return false;
            }
            if (this.selectedList[index]['pledgedQty'] > this.selectedList[index]['currentAmount']) {
                this.yh_message_warn('"质押数量"须小于等于"实时持仓数量"！');
                return false;
            }
            if (moment(this.selectedList[index]['endDate']).isBefore(moment(instruction.endSettleDate).format('YYYYMMDD'))) {
                this.yh_message_warn('质押券的"债券到期日"不能早于"到期结算日期"！');
                return false;
            }
        }

        return true;
    }

    // 组装指令信息
    createInstruction(instruction, stockInfo) {
        instruction.outerOrderCode = instruction.requestId;
        instruction.orderUser = getUser().userCode;
        instruction.orderPurpose = '15';
        if (instruction.instType !== '7') {
            instruction.investType = '1';
        }
        instruction.orderLevel = '0';
        instruction.remark = ' ';
        instruction.instructionType = this.InstTypePojo[instruction.instType];
        // instruction.orderType = '1';
        if (instruction.instType === '4') {
            // 银行间回购
            instruction.marketCode = '5';
            instruction.orderPriceType = '1';
            instruction.orderAmount = Number(instruction.orderBalance) / 100;
            instruction.orderPrice = instruction.orderRate;
            instruction.reportCode = stockInfo.reportCode || instruction.reportCode;
            instruction.businClass = instruction.businessType;
            instruction.instructionType = '2';

            instruction.instructionTypeName = instruction.businessType;
            instruction.interest = instruction.shouldInterest;
            instruction.pledgePOList = this.pledgePOList;
        }
        return instruction;
    }

    /**
     * 到期日期计算公式
     */
    calcEndSettleDate(instruction) {
        if (Number(instruction.repoDay || 0) === 0) {
            return instruction.firstSettleDate;
        } else {
            return this.tradeDays.find(
                item =>
                    instruction.firstSettleDate &&
                    item >= Number(moment(instruction.firstSettleDate, 'YYYYMMDD').add(Number(instruction.repoDay), 'd').format('YYYYMMDD'))
            );
        }
    }

    /**
     * 实际占款天数计算公式   实际占款天数=到期日期-结算日期
     */
    calcFactUseMoney(instruction) {
        if (!instruction.endSettleDate || !instruction.firstSettleDate) {
            return '';
        }
        return moment(instruction.endSettleDate, 'YYYYMMDD').diff(moment(instruction.firstSettleDate, 'YYYYMMDD'), 'days').toString();
    }

    // 试算
    async handlecCalculate(orderType: string) {
        const isUpdate = this.isUpdate;

        let instruction = JSON.parse(JSON.stringify(this.instructionCache || {}));
        let stockInfo = this.stockInfoCache || {};

        // 自动填上到期日期和实际占款天数
        if (this.activeKey === '4') {
            if (this.instructionCache.repoDay && this.instructionCache.repoDay > 366) {
                this.yh_message_warn('回购天数不能超过366天，请重新输入');
                return;
            }
            if (!this.instructionCache.endSettleDate && this.instructionCache.endSettleDate !== '') {
                this.instructionCache.endSettleDate = this.calcEndSettleDate(this.instructionCache)?.toString();
                this.instructionCache.factUseMoney = this.calcFactUseMoney(this.instructionCache);
            }
            if (this.instructionCache.factUseMoney && Number(this.instructionCache.factUseMoney) < Number(this.instructionCache.repoDay)) {
                this.yh_message_warn('实际占款天数不能小于回购天数，请重新输入');
                return;
            }
        }

        if (!instruction) {
            this.yh_message_warn('请填写相关信息');
            return;
        }
        instruction.requestId = UUID() + '-' + new Date().getTime();
        instruction.instType = this.activeKey;
        let verInt = await this.verifyInstructionParam(instruction, stockInfo);
        if (!verInt) {
            return;
        }
        instruction = this.createInstruction(instruction, stockInfo);
        instruction.orderType = orderType;
        this.calcLoading = true;
        instruction.orderPrice = instruction.orderPrice ? instruction.orderPrice : '0';
        let start = window.performance.now();

        // 获取当前提交时间 (试算/下单时间)
        // 补零
        let fillZero = n => {
            let result = n.toString().length === 1 ? '0' + n : n;
            return result;
        };
        // 时间戳转换 yyyy-MM-dd
        let formatTime = (t = new Date()) => {
            let d = new Date(t);
            let year = d.getFullYear();
            let month = d.getMonth() + 1;
            let date = d.getDate();
            let hours = d.getHours();
            let minutes = d.getMinutes();
            let seconds = d.getSeconds();
            let result = `${year}-${fillZero(month)}-${fillZero(date)} ${fillZero(hours)}:${fillZero(minutes)}:${fillZero(seconds)}`;
            return result;
        };
        this.calcTime = formatTime(new Date());

        this.instruction = instruction;
        // 试算表单
        let calcForm: any = {
            orderType: orderType,
            multiType: '2',
            requestId: instruction.requestId,
            instructionType: instruction.showType == '6' ? '4' : this.InstTypePojo[instruction.instType],
            outOrderBatchCode: UUID() + new Date().getTime(),
            tradeUser: getUser().userCode,
            calculateEntryGroup: this.selectEntryGroupCode.calculateEntryGroup,
            excludeEntryGroup: this.selectEntryGroupCode.excludeEntryGroup,
            instList: [instruction],
        };

        // 下单表单
        let placeOrderForm: any = {
            orderType: orderType,
            multiType: '2',
            cancelType: '1',
            requestId: instruction.requestId,
            instructionType: instruction.showType == '6' ? '4' : this.InstTypePojo[instruction.instType],
            outOrderBatchCode: UUID() + new Date().getTime(),
            tradeUser: getUser().userCode,
            calculateEntryGroup: this.selectEntryGroupCode.calculateEntryGroup,
            excludeEntryGroup: this.selectEntryGroupCode.excludeEntryGroup,
            instList: [instruction],
        };

        if (orderType == '1') {
            this.form = JSON.parse(JSON.stringify(calcForm));
        } else {
            this.form = JSON.parse(JSON.stringify(placeOrderForm));
        }
        if (isUpdate) {
            this.form.excludeSerialNoSet = [this.serialNo];
        } else {
            this.form.excludeSerialNoSet = [];
        }
        await trialCalculate(this.form)
            .then(resList => {
                if (resList) {
                    const h = this.$createElement;
                    // 风控结果
                    this.riskResult = resList.thresholdType;
                    this.result = resList.thresholdType;
                    let end = window.performance.now();
                    // 计算耗时
                    this.takeTime = ((end - start) / 1000).toFixed(3) + '秒';
                    if (!this.isPlaceOrder) {
                        this.yh_message_success('提交试算信息成功');
                    }
                    let stockInfo = this.stockInfoCache || {};
                    this.stockInfoPojo = JSON.parse(JSON.stringify(stockInfo));
                    let data = resList.resultList || [];
                    // 根据产品代码 匹配产品名称
                    data.forEach(ele => {
                        ele.requestId = resList.requestId;
                        if (!ele.stockCode || ele.stockCode === ' ') {
                            ele.stockCode = this.stockInfo.stockCode;
                        }
                        for (let i = 0; i < this.fundCodeSelectData.length; i++) {
                            const item = this.fundCodeSelectData[i];
                            if (ele.fundCode === item.fundCode) {
                                ele.fundNameSt = item.fundNameSt;
                            }
                        }
                        ele.stockNameSt = this.stockInfoPojo.stockNameSt;
                    });

                    this.riskOrderResultTable = JSON.parse(JSON.stringify(data));
                    if (orderType === '2') {
                        if (this.result === '0') {
                            this.orderCancelShow = false;
                            this.handleResetForm();
                            this.handleResetResult();
                            this.$message.success({
                                message: h('p', null, [
                                    h('span', null, '本次风控下单结果为'),
                                    h('span', { style: 'color: #70b603' }, '"合规"'),
                                    h('span', null, '，已下单成功'),
                                ]),
                                showClose: true,
                                customClass: 'messageStyle',
                            });
                            if (isUpdate) {
                                this.handleUpdateCancel();
                            }
                            this.isUpdate = false;
                        } else {
                            console.log('下单触发非合规');
                            this.riskOrderResultAfterKey++;
                            this.orderCancelShow = true;
                        }
                        // if (isUpdate) {
                        //     this.handleUpdateCancel();
                        // }
                    }
                    // 如果结果是合规或者是试算就填充数据，否则等待用户选择完之后填充数据
                    if (this.result == '0' || orderType === '1') {
                        this.$set(this, 'riskResultTable', data);
                        // this.resultFilterList = [];
                        // this.pageChangeResult(1);
                        // this.tableData = data;
                        this.calcLoading = false;
                    }
                } else {
                    this.riskResultTable = [];
                    this.calcLoading = false;
                    this.riskResult = '';
                    this.calcTime = '';
                    this.takeTime = '';
                }
            })
            .catch(() => {
                this.calcLoading = false;
            });
    }

    // 修改指令撤单
    handleUpdateCancel() {
        cancelCommonOrder({
            cancelOrderType: '2',
            tradeUser: getUser().userCode, // 当前用户
            tradeUserName: getUser().userName, // 当前用户
            orderType: '4',
            instructionType: '10',
            instNo: '',
            originOuterOrderCode: this.oldOuterOrderCode,
            outerOrderCode: UUID() + '-' + new Date().getTime(),
            requestId: UUID() + '-' + new Date().getTime(),
            delOriginOuterOrderCodeList: [this.oldOuterOrderCode],
        })
            .then(res => {})
            .catch(err => {
                this.yh_message_success(err);
            });
    }

    // 数组排序
    // 对象数组排序
    sortBy(props, sortType) {
        return function (a, b) {
            if (sortType == 'desc') {
                return b[props] - a[props];
            } else {
                return a[props] - b[props];
            }
        };
    }

    test() {
        this.orderCancelShow = false;
        this.isPlaceOrder = false;
        this.handlecCalculate('1');
    }

    handlePlaceOrderClick() {
        this.result = '';
        this.isPlaceOrder = true;
        this.handlecCalculate('2');
    }

    // 清空试算结果
    handleResetResult() {
        this.riskResultTable = [];
        this.riskResult = '';
        this.calcTime = '';
        this.takeTime = '';
    }

    // 处理选择结果返回
    riskResultContinue() {
        console.log('继续下达');
        this.calcLoading = false;
        this.handleResetForm();
        this.handleResetResult();
        // this.riskResultTable = this.riskOrderResultTable;
        if (this.isUpdate) {
            this.handleUpdateCancel();
        }
        this.yh_message_success('指令下达成功');
        this.isUpdate = false;
    }

    // 取消
    riskResultCancel() {
        this.calcLoading = false;
        // this.riskResultTable = [];
        console.log('终止下达');
        cancelCommonOrder({
            cancelOrderType: '2',
            tradeUser: getUser().userCode, // 当前用户
            tradeUserName: getUser().userName, // 当前用户
            orderType: '4',
            instructionType: '10',
            instNo: '',
            originOuterOrderCode: this.instruction.outerOrderCode,
            outerOrderCode: UUID() + '-' + new Date().getTime(),
            requestId: UUID() + '-' + new Date().getTime(),
            delOriginOuterOrderCodeList: [this.instruction.outerOrderCode],
        }).then(res => {
            this.yh_message_success('已终止指令下达');
        });
    }

    /* ************************ 表格处理相关start *************************** */

    // 获取对象长度
    getObjectLength(obj: any) {
        if (obj) {
            return Object.keys(obj).length;
        } else {
            return 0;
        }
    }

    // 获取可投余量、最大可交易量名称
    getShowName(name: string) {
        if (name == 'investableBalance') {
            return '可投余量';
        } else if (name == 'maxTradable') {
            return '最大可交易量';
        } else if (name == 'maxTradableMerge') {
            return '最大可交易量(汇总)';
        }
    }

    // 获取字段名
    getParamName(name: string) {
        return name == 'investableBalance' ? 'INVESTABLE_BALANCE_' : name == 'maxTradable' ? 'MAX_TRADABLE_' : 'MAX_TRADABLE_';
    }

    // 转表格筛选下拉框数据
    objToArr(param) {
        let list = [];
        for (let key in param) {
            list.push({ label: param[key], value: key });
        }
        return list;
    }

    customSortMethod({ data, sortList }) {
        const sortItem = sortList[0];
        // 取出第一个排序的列
        const { property, order } = sortItem;
        let YHList = [];
        let NoYHlist = [];
        let list = [];
        let key = /^[a-zA-Z]+$/;
        data.forEach(ele => {
            if (ele.entryCode.match('.*[A-Z]+.*') || ele.entryCode.match('.*[a-z]+.*')) {
                YHList.push(ele);
            } else {
                NoYHlist.push(ele);
            }
        });

        if (order === 'asc' || order === 'desc') {
            if (property === 'entryCode') {
                YHList.sort(this.compare('entryCode'));
                NoYHlist.sort(this.compare('entryCode'));
                list = NoYHlist.concat(YHList);
                if (order === 'desc') {
                    list.reverse();
                }
            } else {
                list = data.slice().sort(this.sortBy(property, order));
            }
        }
        return list;
    }

    compare(property) {
        return function (a, b) {
            var value1 = a[property];
            var value2 = b[property];
            if (value1.length < 10 && value2.length < 10) {
                var f = '0000000000'; // 10个0
                var aa = f.substring(0, 10 - ('' + value1).length) + value1;
                var bb = f.substring(0, 10 - ('' + value2).length) + value2;
                return aa > bb ? 1 : -1;
            } else {
                return value1 > value2 ? 1 : -1;
            }
        };
    }

    filterThresholdType({ value, row, column }) {
        return row.thresholdType == value;
    }

    filterEntryTypeMethod({ value, row, column }) {
        return row.entryType == value;
    }

    // 表格列筛选数据
    filterHandler({ option, row, column }) {
        const property = column['property'];
        return row[property].includes(option.data);
    }

    formatterCell({ cellValue }) {
        return cellValue || '--';
    }

    changeTable() {
        this.$nextTick(() => {
            let nodeName = [];
            let icon = [];
            if (!this.iconDom) {
                let obj = document.querySelector('.risk-order-bottom');
                this.iconDom = obj.querySelectorAll('.vxe-icon--funnel');
                this.iconDom.forEach((ele: any, index) => {
                    if (!['风险类型', '阈值类型'].includes(ele.parentNode.parentNode.children[0].innerHTML)) {
                        icon.push(index);
                    }
                });
                for (let i = 0; i < 8; i++) {
                    icon.forEach(ele => {
                        if (ele === i) {
                            this.iconDom[i].className = 'vxe-filter--btn el-icon-search';
                        }
                    });
                }
            }
        });
    }

    /* ************************** 表格处理相关end ***************************** */

    /* **************************** 布局设置start ***************************** */
    // 获取页面布局信息
    async queryLayout() {
        this.calcLoading = true;
        let resList: any = await new Promise((resolve, reject) => {
            this.$axios('/tableLayout/query/RE_TRIAL_CALCULATE')
                .then((res: any) => {
                    resolve(res);
                })
                .catch(err => {
                    reject(err);
                });
        });
        if (resList) {
            this.selectedFieldList = JSON.parse(resList);
            this.showFieldList = this.fixedFieldList.concat(this.selectedFieldList);

            this.calcLoading = false;
        } else {
            this.showFieldList = this.tableColumns;
            this.selectedFieldList = this.tableColumns;
            this.calcLoading = false;
        }
        this.showFieldList.forEach((ele: any) => {
            if (['fundCode', 'assetCode', 'fundAccountCode', 'stockCode', 'entryCode'].includes(ele.id)) {
                this.$set(ele, 'sortable', true);
            }
            if (
                [
                    'fundCode',
                    'fundNameSt',
                    'assetCode',
                    'assetName',
                    'fundAccountCode',
                    'fundAccountName',
                    'stockCode',
                    'stockNameSt',
                    'entryCode',
                    'entryName',
                ].includes(ele.id)
            ) {
                this.$set(ele, 'filterMethod', this.filterHandler);
                this.$set(ele, 'filters', [{ data: '' }]);
                this.$set(ele, 'search', true);
            }
            if (ele.id == 'entryType') {
                this.$set(ele, 'filterMethod', this.filterEntryTypeMethod);
                this.$set(ele, 'filters', this.entryTypeArr);
            }
            if (ele.id == 'thresholdType') {
                this.$set(ele, 'filterMethod', this.filterThresholdType);
                this.$set(ele, 'filters', this.ThresholdTypeArr);
            }

            // 重新渲染表格
            this.changeTable();
            this.tableKey++;
        });
    }

    /**
     * 提交成功后回调
     * @param {Object} 回调数据
     */
    async onSubmit(data) {
        await this.queryLayout();
        this.iconDom = null;
        this.changeTable();
        this.tableKey++;
    }

    /* ************************** 布局设置end *******************************/

    /* ************************************ 条目组设置start ********************************** */
    openEntryGroup() {
        this.transDialog = true;
    }

    getEntryGroup(value: any) {
        this.selectEntryGroupCode.calculateEntryGroup = value.calculateEntryGroup;
        this.selectEntryGroupCode.excludeEntryGroup = value.excludeEntryGroup;
    }

    closeEntryDialog() {
        this.transDialog = false;
        this.getUserSelectEntryGroupList();
    }

    getUserSelectEntryGroupList() {
        this.$axios.get('/entry/group/user/select/list/' + this.resourceCode).then((res: any) => {
            res = res || [];
            let selectEntryGroupCode = {
                calculateEntryGroup: res.filter(item => item.instGroupType === '1' && item.groupCode !== 'DEFAULT').map(item => item.groupCode),
                excludeEntryGroup: res.filter(item => item.instGroupType === '2' && item.groupCode !== 'DEFAULT').map(item => item.groupCode),
            };
            this.selectEntryGroupCode.calculateEntryGroup = selectEntryGroupCode.calculateEntryGroup;
            this.selectEntryGroupCode.excludeEntryGroup = selectEntryGroupCode.excludeEntryGroup;
        });
    }

    /* ************************************ 条目组设置end ********************************** */
}
</script>
<style lang="scss" scoped>
@import '@/pages/risk-measure/style/measure';
@import '@/pages/risk-time/styles/risk-order';
.risk-order-top {
    height: calc(72vh - 40px) !important;
    min-height: 470px !important;
    .form-col .form-content {
        height: calc(100% - 35px) !important;
    }
    .vxe-table {
        // height: 100%;
        .el-button-group {
            line-height: 28px;
        }
        /deep/.vxe-table--main-wrapper {
            height: 100%;
        }

        /deep/.el-input__inner {
            height: 28px !important;
            line-height: 28px !important;
        }
    }
    .tableButton {
        padding: 5px 10px;
    }
}
.risk-order-bottom {
    height: 25vh !important;
}
</style>
<style lang="scss">
.messageStyle {
    background-color: #ecf9e3;
    border-color: #ecf9e3;
    font-size: 18px;
    .el-icon-success {
        color: #67c23a;
    }
}
.messageBoxStyle {
    background-color: #ecf9e3;
    border-color: #ecf9e3;
    .el-message-box__header {
        padding: 0 15px 10px;
    }
    .el-message-box__btns {
        text-align: center;

        button:first-of-type {
            background-color: #67c23a;
            border-color: #67c23a;
            color: #fff;
        }
        button:nth-of-type(2) {
            background-color: #a30014;
            border-color: #a30014;
            color: #fff;
        }
    }
}
</style>
